package org.longgang.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.longgang.bean.CompanyInfo;
import org.longgang.bean.Position;
import org.springframework.stereotype.Repository;

/**
 * PositionDAO继承基类
 */
@Repository
@Mapper
public interface PositionDAO extends MyBatisBaseDao<Position, Integer> {
	
	@Insert({ "INSERT INTO `position`(companyid,`position`,`workplace`,`classification`,`department`,`salary`,`edurequest`,`experience`,`statement`,`email`,`deaddate`,b1,b2,`status`) VALUES(#{companyid},#{position},#{workplace},#{classification},#{department},#{salary},#{edurequest},#{experience},#{statement},#{email},#{deaddate},#{b1},#{b2},0)" })
	Integer insertPosition(Position info);

	@Update({"update `position` set `position`=#{position},`workplace`=#{workplace},`classification`=#{classification},`department`=#{department},`salary`=#{salary},`edurequest`=#{edurequest},`experience`=#{experience},`statement`=#{statement},`email`=#{email},`deaddate`=#{deaddate},b1=#{b1},b2=#{b2} where positionid=#{positionid}" })
	Integer updatePosition(Position info);

	@Update({"update `position` set `status`=#{status} where positionid=#{positionid}" })
	Integer changePosition(Position info);
	
	@Select({ "select * from  `position` where companyid=#{companyid} and `status`=#{status} order by releasedate desc"})
	List<Position> selectPosition(Position info);
	
	@Select({ "select * from  `position` where `status`=#{status} order by releasedate desc limit #{page},#{pages}"})
	List<Position> selectAllPosition(Integer status,Integer page,Integer pages);
	
	@Select({ "select * from  `position` where `positionid`= #{positionid}" })
	Position selectPositionById(Position info);
	
	@Select({ "select sum(1) from  `position` where companyid= #{companyid} and `status`=#{status}"})
	Integer sumPosition(Position info);
	
	@Select({ "select sum(1) from  `position` where `status`=#{status}"})
	Integer sumAllPosition(Position info);
	
	@Select({ "select sum(1) from  `position` where `status`=#{status} and `position` like '${dat}'"})
	Integer sumSomePosition(Integer status,String dat);
	
	@Select({ "select * from  `position` where `status`=#{status} and `position` like '${dat}' order by releasedate desc limit #{page},#{pages}"})
	List<Position> selectSomePosition(Integer status,String dat,Integer page,Integer pages);
}